home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_gen
/
wdj0796.zip
/
NELSON.ZIP
/
FIGURE1.TXT
< prev
Wrap
Text File
|
1996-04-08
|
910b
|
33 lines
Output from BUG0796.CPP:
Even though A has no data members, it
still has to occupy a minimum of one
byte according to the C++ standard.
Class B has a single pointer, so under a
32 bit programming model, it should be
exactly four bytes larger.
Unfortunately, VC++ forgets to add that
extra byte from the base class:
sizeof( A ) = 1 sizeof( B ) = 4
As the two constructors are called, note
the addresses of the two memory buffers
that have been allocated for the names
of the objects:
in ctor p = 0x00650540, name = object b1
in ctor p = 0x00650648, name = object b2
When the assignment operator is
invoked, the buffer values for this and
that should match what you see printed
out from the constructors:
buffer::operator=( that ) that.p = 0x00650540, object b1
this->p = 0x00650640,
Since the pointer has been mangled,
expect a GPF upon exit!